	
	function showFrom(type){
		document.getElementById('light').style.display='block';
		document.getElementById('fade').style.display='block';
		
		var serviceFromHtml = 
			//'<form action="">'+
				'<table id="tableFrom" align="center" style="margin-top:50px;">'+
					'<tr>'+
						'<td style="text-align: right;width:100px;">联系人：</td>'+
						'<td><input id="contacts" name="service.contacts" type="text" value="" style="height: 30px"/></td>'+
						'<td style="text-align: right;width:100px;">联系电话：</td>'+
						'<td><input id="tel" name="service.tel" type="text" value="" style="height: 30px"/></td>'+
					'</tr>'+
					'<tr>'+
						'<td style="text-align: right;width:100px;">需要服务：</td>'+
						'<td><span id="type" name="service.type" style="height: 30px"></span></td>'+
						'<td style="text-align: right;width:100px;">邮箱：</td>'+
						'<td><input id="email" name="service.email" type="text" value="" style="height: 30px"/></td>'+
					'</tr>'+
				'</table>'+
				'<div style="margin-top:20px;"><a href="JavaScript:void(0)" style="float:right;margin-right:20px;" onclick="closeFrom()">取消</a>'+
				'<a href="JavaScript:void(0)" style="float:right" onclick="submit('+type+')">提交</a></div>'
			//'</form>'
			;
		
		var typeName="";
		switch(type){
			case 1: typeName = "业务系统开发";
			break;
			case 2: typeName = "移动应用开发";
			break;
			case 3: typeName = "电商平台开发";
			break;
			case 4: typeName = "门户网站开发";
			break;
			case 5: typeName = "系统运维";
			break;
			case 6: typeName = "咨询";
			break;
		}
		$("#serviceForm").html(serviceFromHtml);
		document.getElementById("type").innerText=typeName;
	}
	
	function submit(type){
		var input = document.getElementById("tableFrom").getElementsByTagName("input");
		for(var i=0;i<input.length;i++){
			if(input[i].value.trim()==""||input[i].value.trim()==null){
				alert("请填入信息");
				return;
			}
		}
		var contacts = $("#contacts").val();
		var tel = $("#tel").val();
		if(!/^1\d{10}$/g.test(tel)){
			alert("输入正确的电话");
			return;
		}
		var email = $("#email").val();
		if(!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email)){
			alert("输入正确的邮箱");
			return;
		}
		var typeName="";
		switch(type){
			case 1: typeName = "业务系统开发";
			break;
			case 2: typeName = "移动应用开发";
			break;
			case 3: typeName = "电商平台开发";
			break;
			case 4: typeName = "门户网站开发";
			break;
			case 5: typeName = "系统运维";
			break;
			case 6: typeName = "咨询";
			break;
		}
		$.ajax({
			type:'POST',
			url:'addService.action',
			data:'service.contacts='+contacts+'&service.tel='+tel+'&service.email='+email+'&service.type='+typeName,
			success:function(data){
				if(data=="\"submited\""){
					alert("提交成功");
					window.location.reload();
				}else{
					alert("由于未知原因提交失败");
					window.location.reload();
				}
			}
		});
		
	}
	
	//关闭图片信息框
	function closeFrom(){
		document.getElementById('light').style.display='none';
		document.getElementById('fade').style.display='none';
	}